package com.twotwoshop.service.goods.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.twotwoshop.domin.category.dtos.CategoryDto;
import com.twotwoshop.domin.category.pojos.ProductCategory;
import com.twotwoshop.domin.common.dtos.ResponseResult;
import com.twotwoshop.service.goods.service.ProductCategoryService;
import lombok.RequiredArgsConstructor;
import com.twotwoshop.service.goods.mapper.ProductCategoryMapper;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class ProductCategoryServiceImpl implements ProductCategoryService {

    private final ProductCategoryMapper categoryMapper;


    /**
     * 获取分类列表
     */
    @Override
    public ResponseResult list() {

        // 构建查询条件
        LambdaQueryWrapper<ProductCategory> queryWrapper = new LambdaQueryWrapper<>();
        // 只查询状态为1（启用）的分类
        queryWrapper.eq(ProductCategory::getStatus, 1);
        // 按创建时间倒序排序
        queryWrapper.orderByDesc(ProductCategory::getCreatedTime);
        // 限制只查询前8个
        queryWrapper.last("LIMIT 10");

        // 执行查询
        List<ProductCategory> categoryList = categoryMapper.selectList(queryWrapper);


        return ResponseResult.okResult(categoryList);
    }


    /**
     * 添加分类
     *
     * @param categoryDto
     */
    @Override
    public ResponseResult add(CategoryDto categoryDto) {
        return null;
    }

    /**
     * 修改分类
     *
     * @param categoryDto
     */
    @Override
    public ResponseResult update(CategoryDto categoryDto) {
        return null;
    }

    /**
     * 删除分类
     *
     * @param id
     */
    @Override
    public ResponseResult delete(Long id) {
        return null;
    }

    /**
     * 获取分类详情
     *
     * @param id
     */
    @Override
    public ResponseResult getById(Long id) {
        return null;
    }


    /**
     * 获取分类树
     */
    @Override
    public ResponseResult tree() {
        return null;
    }

    /**
     * 修改分类状态
     *
     * @param id
     * @param status
     */
    @Override
    public ResponseResult updateStatus(Long id, Integer status) {
        return null;
    }
}